//
//  UIButton+LLZ.m
//  xxShare
//
//  Created by 柳麟喆 on 2018/3/5.
//  Copyright © 2018年 lzLiu. All rights reserved.
//

#import "UIButton+LLZ.h"
#import <objc/runtime.h>

static const void *UIButtonBlockKey = &UIButtonBlockKey;
@implementation UIButton (LLZ)

- (void)addHander:(TouchedBlock)touchedHander{
    if (touchedHander) {
        objc_setAssociatedObject(self, UIButtonBlockKey, touchedHander, OBJC_ASSOCIATION_COPY_NONATOMIC);
        [self addTarget:self action:@selector(handerAction:) forControlEvents:UIControlEventTouchUpInside];
    }
}

-  (void)handerAction:(UIButton *)btn{
    TouchedBlock block = objc_getAssociatedObject(self, UIButtonBlockKey);
    block();
}

@end
